/**
 * 如果某个串是由一对一对的字符拼接而成，就称之为偶串
 * 给定S，问最长的偶串子串的长度
 * 令Ui为以i结尾的最长偶串长度，Di为i以内的最长偶子串长度
 * 则
 * S[i] == S[i-1]时， Ui = 2 + U[i-2]
 * 否则, Ui = 0
 * Di = max(U[i], D[i-1])
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>

using llt = long long;
using vi = vector<int>;

int N, M;
string S;

int proc(){
    N = S.length();
    vi D(N, 0);
    vi U(N, 0);
    for(int i=2;i<N;++i){
        if(S[i] == S[i - 1]){
            U[i] = U[i - 2] + 2;
        }else{
            U[i] = 0;
        }
        D[i] = max(U[i], D[i - 1]);
    }
    return D[N - 1];
}


int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> S;
    S = " " + S;
    cout << proc() << endl; 
    return 0;
}